<?php
	header("Content-Type: text/html;charset=utf-8");
	include("function/_nosql.php"); //
	include("function/function.php");
	include("_include.user.judge.php");
	$kboy_userid = $_SESSION['kboy_userid'];
	$kboy_user = $_SESSION['kboy_user'];

	$action = chkstr(trim($_REQUEST['action']));
	$map_prov = chkstr(trim($_REQUEST['map_prov']));
	$map_city = chkstr(trim($_REQUEST['map_city']));
	$map_area = chkstr(trim($_REQUEST['map_area']));
	$map_km = chkstr(trim($_REQUEST['map_km']));
	$map_jingdian = chkstr(trim($_REQUEST['map_jingdian']));
	$map_year = chkstr(trim($_REQUEST['mar_year']));
	$map_month = chkstr(trim($_REQUEST['mar_month']));
	$map_text = chkstr(trim($_REQUEST['map_text']));
	
	if($action == "add"){
		if(strlen($map_prov)<1){
			echo erro("省份不能为空！");
		}
		if(strlen($map_city)<1){
			echo erro("城市不能为空！");
		}
		if(strlen($map_area)<1){
			echo erro("足迹不能为空！");
		}
		if(strlen($map_km)<1){
			echo erro("徒步公里不能为空！");
		}
		if(strlen($map_jingdian)<1){
			echo erro("景点不能为空！");
		}
		if(!isNumber($map_km)){
			echo erro("徒步公里不能为空！");
		}
		if(!isNumber($map_jingdian)){
			echo erro("景点不能为空！");
		}

		// 添加内容
		$mysql = new sqlstr("kboy_forum_map"); 
		$mysql -> set("map_prov",$map_prov);
		$mysql -> set("map_city",$map_city);
		$mysql -> set("map_area",$map_area);
		$mysql -> set("map_km",$map_km,true);
		$mysql -> set("map_jingdian",$map_jingdian,true);
		$mysql -> set("map_year",$map_year);
		$mysql -> set("map_month",$map_month);
		$mysql -> set("map_text",$map_text);
		$mysql -> set("uid",$kboy_userid);
		$news_sql = $mysql -> insertSql();
		$news_res = mysql_query($news_sql);
		if($news_res){
			//mysql_query("update kboy_user set user_km=user_km+".$map_km.",user_activetime=user_activetime+1 where uid=$kboy_userid");
			echo ok("操作成功","forum_map.php?uid=".$kboy_userid);
		}else{
			echo erro("服务器内部错误");
		}
	}else{
		echo erro("参数错误");
	}
?>